//
//  GAKKINetworkManager.h
//  GANGAIKit
//
//  Created by fh on 2019/11/11.
//  Copyright © 2019 cashchina. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "GAKKINetworkApi.h"

NS_ASSUME_NONNULL_BEGIN

// 请求数据最外层的字典key:外部通过这个key取出响应的数据
FOUNDATION_EXPORT NSString * _Nonnull const GAKKINetworkManagerResponseDataKey;
// 默认请求提示语
FOUNDATION_EXPORT NSString * _Nonnull const GAKKINetworkManagerDefaultRemindText;

// 登录成功通知
FOUNDATION_EXPORT NSString * _Nonnull const GAKKILoginSuccessNotification;
// 注销登录通知
FOUNDATION_EXPORT NSString * _Nonnull const GAKKILogoutSuccessNotification;

/// 请求方式
typedef NS_ENUM(NSInteger, RequestMethod) {
    RequestMethodPost,
    RequestMethodGet
};

/// 网络工具类
@interface GAKKINetworkManager : NSObject

/// 单例对象
+ (instancetype)sharedInstance;

/// 全参数请求方法:更底层,扩展性最大
/// @param requestMethod 请求方式
/// @param innerUrl 请求链接:返回GAKKINetworkApi实力对象的属性,属性即后台的接口,详情见GAKKINetworkApi的实现/或者返回字符串网址
/// @param shouldAutoAddIndicator 是否自动加载指示器,NO的话请求时的提示文本remindText参数无效
/// @param remindText 请求时的提示文本
/// @param parameters 请求参数
/// @param showFullResponseData 是否应该返回无处理的服务器数据,NO的话内部会处理服务器数据,提取出dto字典里的内容,YES的话会直接将后台的源数据全部丢过来不做处理
/// @param success 成功回调
/// @param failure 失败回调
+ (void)baseWholeParameterRequestWithMethod:(RequestMethod)requestMethod innerUrl:(NSString * __nullable (^)(GAKKINetworkApi * __nullable api))innerUrl addIndicator:(BOOL)shouldAutoAddIndicator remindText:(NSString * __nullable)remindText parameters:(NSDictionary * __nullable)parameters showFullResponseData:(BOOL)showFullResponseData success:(void(^ __nullable)(NSDictionary *responseDic))success failure:(void(^ __nullable)(NSError *error))failure;


/// post网络请求:返回处理后的数据
/// @param innerUrl 请求链接:返回GAKKINetworkApi实力对象的属性,属性即后台的接口,详情见GAKKINetworkApi的实现/或者返回字符串网址
/// @param remindText 提示文本
/// @param parameters 请求参数
/// @param success 请求成功回调
/// @param failure 请求失败回调
+ (void)postRequestWithInnerUrlStr:(NSString * __nullable (^)(GAKKINetworkApi * __nullable api))innerUrl remindText:(NSString * __nullable)remindText parameters:(NSDictionary * __nullable)parameters success:(void(^)(NSDictionary *responseDic))success failure:(void(^)(NSError *error))failure;


/// get网络请求:返回处理后的数据
/// @param innerUrl 请求链接:返回GAKKINetworkApi实力对象的属性,属性即后台的接口,详情见GAKKINetworkApi的实现/或者返回字符串网址
/// @param remindText 提示文本
/// @param parameters 请求参数
/// @param success 请求成功回调
/// @param failure 请求失败回调
+ (void)getRequestWithInnerUrlStr:(NSString * __nullable (^)(GAKKINetworkApi * __nullable api))innerUrl remindText:(NSString * __nullable)remindText parameters:(NSDictionary * __nullable)parameters success:(void(^ __nullable)(NSDictionary *responseDic))success failure:(void(^ __nullable)(NSError *error))failure;

/// 取消任务
/// @param urlStr 请求链接
+ (void)cancleTaskWithURLStr:(NSString *)urlStr;

@end

NS_ASSUME_NONNULL_END
